home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93c.txt
/
000012_icon-group-sender _Tue Jul 20 11:00:24 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-02-02
|
1KB
Received: by cheltenham.cs.arizona.edu; Tue, 20 Jul 1993 08:10:00 MST
Date: Tue, 20 Jul 93 11:00:24 EDT
From: Paul_Abrahams@MTS.cc.Wayne.edu
To: icon-group@cs.arizona.edu
Message-Id: <705767@MTS.cc.Wayne.edu>
Subject: Mystery about "every"
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
I thought I understood how "every" works -- at least when I check
everything out in the book -- but I've come across a program whose
behavior leaves me utterly baffled (this under OS/2 V8.8 Icon). Consider
the following example, derived from the program where the problem
appeared:
procedure main()
local retval, c, s
s := "123"
retval := 0
every c := !s do
retval := 8 * retval + ord(c) - ord("0")
write("Octal output is ", retval)
end
This program produced the output 83, as expected. But I then replaced
the "every" statement by the following one, which I thought to be more
elegant:
every retval := 8 * retval + ord(!s) - ord("0")
Now the output of the program is 3 (the last digit), not 83.
Can anyone explain to me what's going on?
Thanks.
Paul Abrahams
Reply-To: abrahams@acm.org